package plus.xj17520.basic.common;

import plus.xj17520.basic.util.FastdfsUtils;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Api(value = "图片上传管理接口",description = "图片上传管理接口")
public class FileController {
    @Autowired
    FastdfsUtils fastdfsUtils;
    @ApiOperation(value = "图片上传", notes = "图片上传")
    @PostMapping("/file/upload")
    public String fileUpLoad( MultipartFile file1) throws IOException {
        StorePath upload = fastdfsUtils.upload(file1);
        String path = upload.getPath();
        String fullPath = upload.getFullPath();
        //System.out.println(path);
        //System.out.println(fullPath);
        return "http://47.95.117.210:8888/"+fullPath;

    }
}

